<template>
  <div>
    <h2>用户管理</h2>
    <!-- 搜索筛选 -->
    <el-form class="user-search">
      <el-form-item>
        <el-button size="small" type="primary">用户管理</el-button>
      </el-form-item>
    </el-form>

    <template>
      <div class="header">
        <el-input
            clearable
            v-model="searchName"
            style="width: 10%; margin-right: 10px;margin-left: 30px"
            size="small"
            placeholder="请输入用户姓名"/>
        <el-button type="success" size="small" @click="search">查询</el-button>
      </div>
    </template>
    <!--列表-->
    <el-table
        size="small"
        style="margin: 30px;"
        empty-text="无数据"
        :data="userList"
        highlight-current-row v-loading="loading" border element-loading-text="拼命加载中">
      <el-table-column align="center" sortable prop="name" label="姓名" width="130"></el-table-column>
      <el-table-column align="center" sortable prop="nickName" label="用户昵称" width="150"></el-table-column>

      <el-table-column label="操作" width="120">
        <template slot-scope="scope">
          <el-button type="danger" size="mini" icon="el-icon-edit" @click="openUpdate(scope.$index, scope.row)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--弹出窗口、添加、修改-->
    <!-- 编辑界面 -->
    <el-dialog :title="editTitle" :visible.sync="editFormVisible" width="30%" @click='closeDialog("edit")'>
      <el-form
          label-width="150px"
          :model="userInfo"
          ref="userInfo">
        <el-form-item label="用户昵称" prop="nickName">
          <el-input :disabled="true" size="small" v-model="userInfo.nickName" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input :disabled="true" size="small" v-model="userInfo.name" auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align: center">
        <el-button size="small" @click='closeDialog("edit")'>取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitEditForm()">保存</el-button>
      </div>
    </el-dialog>
    <!-- 分页 -->
    <el-pagination class="pagination" style="text-align: center;margin-top: 50px"
                   layout="prev, pager, next"
                   :current-page="page"
                   :total="total"
                   :page-size="limit"
                   @current-change="fetchData">
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: "user",
  data() {
    return {
      editTitle: '审核用户',
      editFormVisible: false, //控制编辑页面显示与隐藏

      total: 0, // 数据库中的总记录数
      page: 1, // 默认页码
      limit: 10, // 每页记录数
      count: 0,
      userList:[
        {"nickName": "小鱼儿", "name": "李白"},
        {"nickName": "nike", "name": "王五"}
      ],
      userInfo: {
        nickName:'小鱼儿',
        name: '123'
      },

      searchName: '',

    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
    },
    //更新
    openUpdate(index, userInfo) {
      this.userInfo = userInfo
      this.editFormVisible = true
    },
    submitEditForm() {

    },
    // 关闭编辑、增加弹出框
    closeDialog(dialog) {
      if (dialog == 'edit') {
        this.editFormVisible = false
      } else if (dialog == 'perm') {
        this.dataAccessshow = false
      } else if (dialog == 'unit') {
        this.unitAccessshow = false
      } else if (dialog == 'add') {
        this.addFormVisible = false
      }
    },
  },


}
</script>

<style scoped>

</style>
